/* rwopmxr.p - STANDARD OPERATION REPONSIBILITY OWNING PROGRAM                */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.3 $                                                           */
/*                                                                            */
/* This routine provides the procedures which are executed as a result of the */
/* call from the appropriate Data Type Controllers / structured programs      */
/* This routine owns the business logic for Standard Operation Records        */
/*                                                                            */
/* $Revision: 1.3 $  BY:Anup Pereira    DATE:05/24/00   ECO: *N0DP*           */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00 BY: *N0KP* myb                    */
/* REVISION: 9.1    LAST MODIFIED: 08/21/00 BY: *N0LJ* Mark Brown             */
/*                                                                            */
/*V8:ConvertMode=NoConvert                                                    */

/* ========================================================================== */
/* ******************************* DEFINITIONS ****************************** */
/* ========================================================================== */

/* STANDARD INCLUDE FILES */
{mfdeclre.i}
{pxmaint.i}

/* ========================================================================== */
/* ******************************* MAIN BLOCK ******************************* */
/* ========================================================================== */

/* ========================================================================== */
/* *************************** INTERNAL PROCEDURES ************************** */
/* ========================================================================== */

/*============================================================================*/
PROCEDURE processRead :
/*------------------------------------------------------------------------------
Purpose:      Read the Standard Operation record based on the Standard
                          Operation Id
Exceptions:   RECORD-LOCKED, RECORD-NOT-FOUND
Conditions:
        Pre:  NONE
        Post: opm_mstr(r)

Notes:
History:
------------------------------------------------------------------------------*/
   define input parameter pStdOperation as character no-undo.
   define parameter buffer opm_mstr for opm_mstr.
   define input parameter pLockFlag     as logical   no-undo.
   define input parameter pWaitFlag     as logical   no-undo.

   do on error undo, return error {&GENERAL-APP-EXCEPT}:

      if pLockFlag
      then do:
         if pWaitFlag then
            find opm_mstr where opm_std_op = pStdOperation
            exclusive-lock no-error.
         else
            find opm_mstr where opm_std_op = pStdOperation
            exclusive-lock no-wait no-error.

         if locked opm_mstr then
            return {&RECORD-LOCKED} .
      end. /* if pLockflag then do: */
      else
         for first opm_mstr
            where opm_std_op = pStdOperation
            no-lock: end.

      if not available opm_mstr then
         return {&RECORD-NOT-FOUND}.
   end.
   return {&SUCCESS-RESULT}.
END PROCEDURE. /* processRead */

/*============================================================================*/
PROCEDURE validateFSMStdOp :
/*------------------------------------------------------------------------------
Purpose:      Validate that Standard Operation type is not FSM
Exceptions:
Conditions:
        Pre:  opm_mstr(r)
        Post: Validated Standard Operation Type
Notes:
History:
------------------------------------------------------------------------------*/
   define input parameter pStdOpType as character no-undo.

   do on error undo, return error {&GENERAL-APP-EXCEPT}:
      if pStdOpType = "FSM"
      then do:
         /* MESSAGE #7492 - CONTROLLED BY SERVICE/SUPPORT MODULE */
         {pxmsg.i &MSGNUM=7492
                  &ERRORLEVEL={&WARNING-RESULT}
         }
      end. /* if pStdOpType = "FSM" */
   end.
   return {&SUCCESS-RESULT}.
END PROCEDURE. /* validateFSMStdOp */
